﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;
using System.Data.SqlClient;

/// <summary>
/// Summary description for cls_tbHOADON_LAPPHIEUTHU
/// </summary>
public class cls_tbHOADON_LAPPHIEUTHU
{
	public cls_tbHOADON_LAPPHIEUTHU()
	{
		//
		// TODO: Add constructor logic here
		//
	}
    public static DataTable GetByF_MaCN(string F_MACN)
    {
        DataTable dt = new DataTable();
        DatabaseConnect connect = new DatabaseConnect();
        // Tham so
        SqlParameter[] para = new SqlParameter[1];
        para[0] = new SqlParameter("@F_MACN", F_MACN);
        try
        {
            dt = connect.GetSelectCommand("tbHOADON_LAPPHIEUTHU_GetbyF_MACN", para);
        }
        catch { }
        return dt;
    }
    public static DataTable GetByF_ID(int F_ID)
    {
        DataTable dt = new DataTable();
        DatabaseConnect connect = new DatabaseConnect();
        // Tham so
        SqlParameter[] para = new SqlParameter[1];
        para[0] = new SqlParameter("@F_ID", F_ID);
        try
        {
            dt = connect.GetSelectCommand("tbHOADON_LAPPHIEUTHU_GetbyF_ID", para);
        }
        catch { }
        return dt;
    }
    public static string Insert(string F_MACN,DateTime F_NGAY,string F_NGUOINOPTIEN,string F_SOPHIEUTHU,string F_DIACHI,string F_LIDO,decimal F_SOTIEN,string F_TIENBANGCHU,string F_KEMCHUNGTUGOC,string F_PGD,string F_KETOANTRUONG,string F_NGUOINOPTIEN_KYTEN,string F_NGUOILAPPHIEU,string F_THUQUY,string F_DANHANDUSOTIEN)
    {
        DatabaseConnect connect = new DatabaseConnect();
        // Tham so
        object[] values = { F_MACN, F_NGAY, F_NGUOINOPTIEN, F_SOPHIEUTHU, F_DIACHI, F_LIDO, F_SOTIEN, F_TIENBANGCHU, F_KEMCHUNGTUGOC, F_PGD, F_KETOANTRUONG, F_NGUOINOPTIEN_KYTEN, F_NGUOILAPPHIEU, F_THUQUY, F_DANHANDUSOTIEN };
        string[] parameters = { "@F_MACN", "@F_NGAY", "@F_NGUOINOPTIEN", "@F_SOPHIEUTHU", "@F_DIACHI", "@F_LIDO", "@F_SOTIEN", "@F_TIENBANGCHU", "@F_KEMCHUNGTUGOC", "@F_PGD", "@F_KETOANTRUONG", "@F_NGUOINOPTIEN_KYTEN", "@F_NGUOILAPPHIEU", "@F_THUQUY", "@F_DANHANDUSOTIEN" };
        SqlParameter[] para = new SqlParameter[parameters.Length];
        for (int i = 0; i < parameters.Length; i++)
        {
            para[i] = new SqlParameter(parameters[i], values[i]);
        }
        try
        {
            connect.ExecuteQuery("tbHOADON_LAPPHIEUTHU_Insert", para);
            return "OK";
        }
        catch
        {
            return "ERR";
        }
    }
    public static string Update(int F_ID,string F_MACN, DateTime F_NGAY, string F_NGUOINOPTIEN, string F_SOPHIEUTHU, string F_DIACHI, string F_LIDO, decimal F_SOTIEN, string F_TIENBANGCHU, string F_KEMCHUNGTUGOC, string F_PGD, string F_KETOANTRUONG, string F_NGUOINOPTIEN_KYTEN, string F_NGUOILAPPHIEU, string F_THUQUY, string F_DANHANDUSOTIEN)
    {
        DatabaseConnect connect = new DatabaseConnect();
        // Tham so
        object[] values = { F_ID, F_MACN, F_NGAY, F_NGUOINOPTIEN, F_SOPHIEUTHU, F_DIACHI, F_LIDO, F_SOTIEN, F_TIENBANGCHU, F_KEMCHUNGTUGOC, F_PGD, F_KETOANTRUONG, F_NGUOINOPTIEN_KYTEN, F_NGUOILAPPHIEU, F_THUQUY, F_DANHANDUSOTIEN };
        string[] parameters = { "@F_ID", "@F_MACN", "@F_NGAY", "@F_NGUOINOPTIEN", "@F_SOPHIEUTHU", "@F_DIACHI", "@F_LIDO", "@F_SOTIEN", "@F_TIENBANGCHU", "@F_KEMCHUNGTUGOC", "@F_PGD", "@F_KETOANTRUONG", "@F_NGUOINOPTIEN_KYTEN", "@F_NGUOILAPPHIEU", "@F_THUQUY", "@F_DANHANDUSOTIEN" };
        SqlParameter[] para = new SqlParameter[parameters.Length];
        for (int i = 0; i < parameters.Length; i++)
        {
            para[i] = new SqlParameter(parameters[i], values[i]);
        }
        try
        {
            connect.ExecuteQuery("tbHOADON_LAPPHIEUTHU_Update", para);
            return "OK";
        }
        catch
        {
            return "ERR";
        }
    }
    public static string Delete(int F_ID)
    {
        DatabaseConnect connect = new DatabaseConnect();
        // Tham so
        object[] values = { F_ID };
        string[] parameters = { "@F_ID" };
        SqlParameter[] para = new SqlParameter[parameters.Length];
        for (int i = 0; i < parameters.Length; i++)
        {
            para[i] = new SqlParameter(parameters[i], values[i]);
        }
        try
        {
            connect.ExecuteQuery("tbHOADON_LAPPHIEUTHU_Delete", para);
            return "OK";
        }
        catch
        {
            return "ERR";
        }
    }
}